var pageContentDiv;
var pageHeaderDiv;

jQuery(document).ready(function() {

	adjustPlacement();
	jQuery(".lobbyTable").corner();
	jQuery(".pageHeader").corner();
	jQuery(".pageContent").corner();

	loginRearrange();
});

function adjustPlacement() {
	margin = parseInt(jQuery("body").width()) * 0.1 > 10 ? parseInt(jQuery(
			"body").width()) * 0.1 : 10;

	pageContentDiv = jQuery(".pageContent");
	pageContentDiv.css({
		"marginLeft" : margin,
		"marginRight" : margin
	});
	pageHeaderDiv = jQuery(".pageHeader");
	pageHeaderDiv.css({
		"marginLeft" : margin,
		"marginRight" : margin
	});

}

function loginRearrange() {
	var myGamesWidth = jQuery(".myGames").width();
	var windowWidth = jQuery(window).width();
	var space = windowWidth * 0.05 > 10 ? windowWidth * 0.05 : 10;
	var myGamesMarginLeft = jQuery(".myGames").css("marginLeft");

	jQuery(".lobby").animate(
			{
				"marginLeft" : parseInt(myGamesWidth)
						+ parseInt(myGamesMarginLeft) + space
			}, 1000);

	jQuery(".myGamesTable").corner();

	jQuery(".myGames").delay(1000).slideToggle(1000, function() {

		jQuery(".newGameButton").show();

	});

}

jQuery(window).resize(
		function() {
			adjustPlacement();
			var myGamesWidth = jQuery(".myGames").width();
			var windowWidth = jQuery("body").width();
			var space = windowWidth * 0.05 > 10 ? windowWidth * 0.05 : 10;
			var myGamesMarginLeft = jQuery(".myGames").css("marginLeft");

			jQuery(".lobby").css(
					{
						"marginLeft" : parseInt(myGamesWidth)
								+ parseInt(myGamesMarginLeft) + space
					});

		});